package com.hy.${packageCode}.shared.dbaccess.entity;

import com.hy.${packageCode}.shared.dbaccess.commont.Comment;
import jakarta.persistence.*;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.domain.Persistable;

import java.io.Serial;
import java.io.Serializable;

@Getter
@Setter
@ToString
@MappedSuperclass
@EqualsAndHashCode(of = "id")
public abstract class AbstractPersistable implements Persistable<Long>, Serializable {
    @Serial
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name = "id")
    @Comment("ID")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;


    @Transient
    public boolean isNew() {
        return null == this.getId();
    }
}
